package com.example.demo.pattern.mixpattern.entity.duck.impl;

import com.example.demo.pattern.mixpattern.entity.duck.QuackAble;
import com.example.demo.pattern.mixpattern.observer.Observable;
import com.example.demo.pattern.mixpattern.observer.Observer;

//鸭鸣器（猎人用）
public class DuckCall implements QuackAble {
    private final Observable observable;

    public DuckCall() {
        observable = new Observable(this);
    }

    @Override
    public void quack() {
        System.out.println("Kwak");//叫得有点假
        notifyObservers();
    }

    @Override
    public void registerObserver(Observer observer) {
        observable.registerObserver(observer);
    }

    @Override
    public void notifyObservers() {
        observable.notifyObservers();
    }
}